var identify_reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
var banknum_reg  = /^([1-9]{1})(\d{15,18})$/;
var username_reg = /^[\u4E00-\u9FA5A-Za-z]+$/;
var phone_reg = /^(13[0-9]|14[0-9]|15[0-9]|18[0-9]|17[0-9]|16[0-9]|19[0-9])\d{8}$/i;
var arr= ['<li index="3"><label>居住地址</label><input type="text" name="liveaddress"  placeholder="请入居住地址"/></li>', 
'<li index="4"><label>公司地址</label><input type="text" name="companyaddress"  placeholder="请入公司地址"/></li>',  
'<li index="5"><label>银行卡号</label><input type="text" name="banknum"  placeholder="请入银行卡号"/></li>' 
];
/**
 * 同盾
 * @param  {String} ){   $(".modal_ul li[index      [description]
 * @return {[type]}                  [description]
 */
$(".peo_tbody td").click(function(){
	$(".modal_ul li[index='3']").remove();
	$(".modal_ul li[index='4']").remove();
	var class_a=$(this).find("a").prop("className");
   $('#credithidden').val(class_a);
   if($(this).index()==1){
   	$(".modal_ul li[index='0']").hide();
   }else if($(this).index()==2){
    $(".modal_ul li[index='0']").show();
   }else if($(this).index()==3){
		if($(".modal_ul li[index='3']").length!=0){
            return true; 
   	    }else{
   	   	 $(".modal_ul").append(arr[0]);
		}

   }else if($(this).index()==4){
   	   if($(".modal_ul li[index='4']").length!=0){
            return true; 
   	   }else{
   	   	 $(".modal_ul").append(arr[1]);
   	   }
   
   }else if($(this).index()==5){
   	   	$(".modal_ul li[index='1']").hide();
	}else if($(this).index()==6){
	   	$(".modal_ul li[index='1']").show();
	} 
})
/**
 * 百融
 * @param  {[type]} ){                var credclss [description]
 * @return {[type]}     [description]
 */
$(".hundredmelt td").click(function(){
   $(".modal_ul li[index='3']").remove();
   $(".modal_ul li[index='4']").remove();
   $(".modal_ul li[index='5']").remove();
   $(".modal_ul li[index='0']").show();
   $(".modal_ul li[index='1']").show();
   $(".modal_ul li[index='2']").show();
   var class_a=$(this).find("a").prop("className");
   $('#credithidden').val(class_a);
   if($(this).index()==5){
         $(".modal_ul").append(arr[2]);
   }else if($(this).index()==6){
         $(".modal_ul li[index='1']").show();
   }
});
$(".hundredmeltlist td").click(function(){
   $(".modal_ul li[index='3']").remove();
   $(".modal_ul li[index='4']").remove();
   $(".modal_ul li[index='5']").remove();
   $(".modal_ul li[index='0']").show();
   $(".modal_ul li[index='1']").show();
   $(".modal_ul li[index='2']").show();
   var class_a=$(this).find("a").prop("className");
   $('#credithidden').val(class_a);
   if($(this).index()==2){
         $(".modal_ul li[index='2']").hide();
   }else if($(this).index()==4){
      $(".modal_ul").append(arr[2]);
   }else{
      $(".modal_ul li[index='2']").show();
   }
   
});

$(".btn-primarycred").click(function(){
   var credclss       = $('#credithidden').val();
   var username       = $('input[name="username"]').val();
   var identify       = $('input[name="identify"]').val();
   var phone          = $('input[name="phone"]').val();
   var banknum        = $('input[name="banknum"]').val();
   var liveaddress    = $('input[name="liveaddress"]').val();
   var companyaddress = $('input[name="companyaddress"]').val();
   data = {creditype:credclss,fullanme:username,identify:identify,tel:phone,banknum:banknum,liveaddress:liveaddress,companyaddress:companyaddress};
   post('/Admin/Credit/reskcheck',data,function(response){
         $('.jiazai').css('display','none');
         $("#myModal").css("display",'none');
         $(".modal-backdrop").css("display",'none');
         if(credclss == "cheattcation"){
            var newp = $('<p class="cheat"></p>');
            if(response.success=='OK'){
               for(i in response.message){
                  $(newp).html('欺诈分二点零'+' ('+response.message[i].scorecard_reason_code+')'+',次数:'+response.message[i].score);
                  $('.cheattcation').after(newp);
                  $('.cheattcation').remove();
               }
            }else if(response.success=='ERROR'&&response.error<10000){
               sweetAlert("",response.message,"warning");
            }else if(response.success=='ERROR'){
               sweetAlert("",response.message,"warning");
            }
         }else if(credclss == "creditcation"){
            var newp = $('<p class="cheat"></p>');
            if(response.success=='OK'){
               if(response.message.decision == "PASS"){
                  var passdec = "通过";
               }else{
                  var passdec = response.message.decision;
               }
               $(newp).html('信用分数'+' ('+response.message.credit_score+',建议:'+passdec+')');
               $('.creditcation').after(newp);
               $('.creditcation').remove();
            }else if(response.success=='ERROR'&&response.error<10000){
               sweetAlert("",response.message,"warning");
               $(newp).html(response.address+' ('+response.message+')');
               $('.creditcation').after(newp);
               $('.creditcation').remove();
            }else if(response.success=='ERROR'&&response.error>=10000){
               sweetAlert("",response.message,"warning");
               return false;
            }else if(response.success=='ERROR'){
               sweetAlert("",response.message,"warning");
               return false;
            }
         }else if(credclss == "homeaddressverification"){
            var newp = $('<p class="jiancxx"></p>');
            if(response.success=='OK'){
               $(newp).html(response.address+' ('+response.message+')');
               $('.homeaddressverification').after(newp);
               $('.homeaddressverification').remove();
            }else if(response.success=='ERROR'&&response.error<10000){
               sweetAlert("",response.message,"warning");
               $(newp).html(response.address+' ('+response.message+')');
               $('.homeaddressverification').after(newp);
               $('.homeaddressverification').remove();
            }else if(response.success=='ERROR'&&response.error>=10000){
               sweetAlert("",response.message,"warning");
            }else if(response.success=='ERROR'){
               sweetAlert("",response.message,"warning");
               return false;
            }
         }else if(credclss == "companyaddressverification"){
            var newp = $('<p class="jiancxx"></p>');
            if(response.success=='OK'){
               $(newp).html(response.address+' ('+response.message+')');
               $('.companyaddressverification').after(newp);
               $('.companyaddressverification').remove();
            }else if(response.success=='ERROR'&&response.error<10000){
               sweetAlert("",response.message,"warning");
               $(newp).html(response.address+' ('+response.message+')');
               $('.companyaddressverification').after(newp);
               $('.companyaddressverification').remove();
            }else if(response.success=='ERROR'&&response.error>=10000){
               sweetAlert("",response.message,"warning");
            }else if(response.success=='ERROR'){
               sweetAlert("",response.message,"warning");
               return false;
            }
         }else if(credclss == "phonewhenlong"){
            var newp = $('<p class="jiancxx"></p>');
            if(response.success=='OK'){
               $(newp).html(response.data);
               $('.phonewhenlong').after(newp);
               $('.phonewhenlong').remove();
            }else if(response.success=='ERROR'&&response.error<10000){
               sweetAlert("",response.message,"warning");
            }else if(response.success=='ERROR'&&response.error>=10000){
               sweetAlert("",response.message,"warning");
            }else if(response.success=='ERROR'){
               sweetAlert("",response.message,"warning");
               return false;
            }
         }else if(credclss =="antifraud"){
               var newp = $('<p class="jiancxx"></p>');
               if(response.success=='OK'){
                  var yc = '';
                  if(response.data){
                     for (var i = 0; i < response.data.length; i++) {
                        yc += response.data[i]+'<br />';
                     }
                  }
                  $(newp).html(yc+'('+response.message+')');
                  $('.antifraud').after(newp);
                  $('.antifraud').remove();
               }else if(response.success=='ERROR'&&response.error<10000){
                  sweetAlert("",response.message,"warning");
               }else if(response.success=='ERROR'&&response.error>=10000){
                  sweetAlert("",response.message,"warning");
               }else if(response.success=='ERROR'){
                  sweetAlert("",response.message,"warning");
                  return false;
               }
         }else if(credclss =="specialList"){
               if(response.success == 'OK'){
                  $(".modle_div").show();
                  $(".modle_div_l").show();
                  $(".close_p_p").show();
                  for( i in  response.hit){
                    
                     $(".uilist").append("<li>"+response.hit[i]+"</li>");
                  }
               }else if(response.success == 'ERROR'){
                   sweetAlert("",response.message,"warning");
                  
               }
         }else if(credclss =="loanIntention"){
               if(response.success == 'OK'){
                  $(".modle_div").show();
                  $(".modle_div_l").show();
                  $(".close_p_p").show();
                  for( i in  response.hit){
                     
                     $(".uilist").append("<li>"+response.hit[i]+"</li>");
                  }
               }else if(response.success == "ERROR"){
                   sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="realNameInfo"){
               if(response.success == 'OK'){
                  $(".modle_div").show();
                  $(".modle_div_l").show();
                  $(".close_p_p").show();
                  for( i in  response.hit){
                     $(".uilist").append("<li>"+response.hit[i]+"</li>");
                  }
               }else if(response.success == "ERROR"){
                   sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="courtExecution"){
               if(response.success == 'OK'){
                  $(".modle_div").show();
                  $(".modle_div_l").show();
                  $(".close_p_p").show();
                  for( i in  response.hit){
                     $(".uilist").append("<li>"+response.hit[i]+"</li>");
                  }
                  // sweetAlert("",response.hit,"warning");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="payConsumption"){
               if(response.success == 'OK'){
                  $(".modle_div").show();
                  $(".modle_div_l").show();
                  $(".close_p_p").show();
                  for( i in  response.hit){
                     $(".uilist").append("<li>"+response.hit[i]+"</li>");
                  }
                  // sweetAlert("",response.hit,"warning");
               }else if(response.success == "ERROR"){
                   sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="badInfo"){
               if(response.success == 'OK'){
                  if(response.hit){
                     sweetAlert("",response.hit,"success");
                  }else{
                     sweetAlert("",response.message,"success");
                  }
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="phoneEssential"){
               if(response.success == 'OK'){
                  sweetAlert("",response.operation+':'+response.result,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="educationInquiries"){
               if(response.success == 'OK'){
                  swal({ 
                    title: "",
                    text: "<p>创建时间:"+response.operation.createDate+"<br/>学历:"+response.operation.educationDegree+"<br/>入学年:"+response.operation.enrolDate+"<br>毕业年:"+response.operation.graduateTime+"<br/>学校:"+response.operation.graduate+"<br/>学校类型:"+response.operation.schoolCategory+"<br/>学校城市:"+response.operation.schoolCity+"<br/>学校级别:"+response.operation.schoolTrade+"<br/>专业"+response.operation.specialityName+"<br/>是否毕业:"+response.operation.studyResult+"<br/>学历:"+response.operation.studyStyle+"</p>", 
                    html: true 
                  });
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="identityVerific"){
               if(response.success == 'OK'){
                  sweetAlert("","身份证号与姓名"+response.message,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="identityVerificAndFind"){
               if(response.success == 'OK'){
                  sweetAlert("",response.message,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="bankFourPro"){
               if(response.success == 'OK'){
                  sweetAlert("","身份证与银行卡:"+response.message,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="telPeriod"){
               if(response.success == 'OK'){
                  sweetAlert("","手机运营商:"+response.operation+"--手机在网时长:"+response.datavalue,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="telStatus"){
               if(response.success == 'OK'){
                  sweetAlert("","手机运营商:"+response.operation+"--手机在网状态:"+response.datavalue,"success");
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }else if(credclss =="scorelargecashv1"){
               if(response.success == 'OK'){
                  // sweetAlert("","取值范围为300-1000分,分数越高代表客户偿还能力越好,违约概率越小:"+response.message,"warning");
                  swal({ 
                    title:"该用户分数为:"+response.message,
                    text: "<p>取值范围为300-1000分,分数越高代表客户偿还能力越好,违约概率越小</p>", 
                    html: true 
                  });
               }else if(response.success == "ERROR"){
                  sweetAlert("",response.message,"warning");
               }
         }

   },'json');
});



// function angdeapi(apitype,response_fun) {
//    datatype.apt_type = apitype;
//    post('/Admin/Credit/bodyGuard',datatype,response_fun,'json');
// }
// function  onehundredapi(api_name,response_fun){
//    dataname.api_name = api_name;
//    post('/Admin/Credit/hundre',dataname,response_fun,'json');
// }
$(".close_p_p").on("click",function(){
   $(".modle_div").hide();
   $(".modle_div_l").hide();
   $(".close_p_p").hide();
})